package com.xcity.game.chat;

import naga.x.game.GameUnit;
import naga.x.game.time.TimeUpdater;


public class ChatMessage {

	protected long time;
	protected ChatChannel channel; // 频道
	protected String content;
	protected long srcId;
	protected String srcName;
	protected String srcIcon; // 发送者头像
	protected long destId;
	protected String destName;
	protected String destIcon;
	
	public ChatMessage() {}
	
	// 系统公告
	public ChatMessage(String content) {
		this(null, null, ChatChannel.SYS, content);
	}
	
	// 公聊
	public ChatMessage(GameUnit src, String content) {
		this(src, null, ChatChannel.PUB, content);
	}
	
	// 私聊
	public ChatMessage(GameUnit src, GameUnit dest, String content) {
		this(src, dest, ChatChannel.PRI, content);
	}
	
	public ChatMessage(GameUnit src, long gid, String content){
		this(src, null, ChatChannel.GLD, content);
		destId = gid;
	}
	
	private ChatMessage(GameUnit src, GameUnit dest, ChatChannel channel, String content) {
		time = TimeUpdater.getInstance().now();
		this.channel = channel;
		this.content = content;
		if (src != null) {
			srcId = src.getId();
			srcName = src.getName();
			srcIcon = src.getIcon();
		} else {
			srcId = -1;
		}
		if (dest != null) {
			destId = dest.getId();
			destName = dest.getName();
			destIcon = dest.getIcon();
		} else {
			destId = -1;
		}
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public ChatChannel getChannel() {
		return channel;
	}

	public void setChannel(ChatChannel channel) {
		this.channel = channel;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public long getSrcId() {
		return srcId;
	}

	public void setSrcId(long srcId) {
		this.srcId = srcId;
	}

	public String getSrcName() {
		return srcName;
	}

	public void setSrcName(String srcName) {
		this.srcName = srcName;
	}

	public String getSrcIcon() {
		return srcIcon;
	}

	public void setSrcIcon(String srcIcon) {
		this.srcIcon = srcIcon;
	}

	public long getDestId() {
		return destId;
	}

	public void setDestId(long destId) {
		this.destId = destId;
	}

	public String getDestName() {
		return destName;
	}

	public void setDestName(String destName) {
		this.destName = destName;
	}

	public String getDestIcon() {
		return destIcon;
	}

	public void setDestIcon(String destIcon) {
		this.destIcon = destIcon;
	}

}
